﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using QuanLyBus.Model;

namespace QuanLyBus
{
    public partial class Them_tram : PhoneApplicationPage
    {
        QL_TuyenDataContext db = new QL_TuyenDataContext(App.constr);
        public Them_tram()
        {
            InitializeComponent();
        }

        private void btn_add_Click(object sender, EventArgs e)
        {

            string duong, so_nha, quan;
            duong = txt_duong.Text;
            so_nha = txt_so_nha.Text;
            quan = txt_quan.Text;
            db.ds_trams.InsertOnSubmit(new ds_tram() {id_tram=10,so_nha=so_nha,duong=duong,quan=quan });
            //db.dstuyens.InsertOnSubmit(new dstuyen() { id_tuyen = id_tuyen_txt, ten_tuyen_den = ten_tuyen_den_txt, ten_tuyen_di = ten_tuyen_di_txt });
            db.SubmitChanges();
            MessageBox.Show("Thêm Thành Công");
            this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            this.NavigationService.GoBack();
        }
        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            this.NavigationService.GoBack();
            base.OnBackKeyPress(e);
        }
    }
}